#include"func_down_freq.h"

#define M_PI 3.1415926

void func_down_freq(complex<double>* data, int data_len, double Fc, double Fs, double ini_phase, complex<double>* data_out, double& phase)
{
    for (int i = 0; i < data_len; i++)
    {
        double t = (double)i / Fs;
        complex<double> cplx_exp = exp(-1i * M_PI * (double)2 * Fc * t - 1i * ini_phase);
        data_out[i] = data[i] * cplx_exp;
    }

    phase = fmod(2 * M_PI * Fc * data_len / Fs + ini_phase, 2 * M_PI);
}

